#include <stdio.h>
#include <stdlib.h>
#include "sorts.h"
 
void insert_sort(ELE_TYPE arr[], int len)
{
	ELE_TYPE tmp;
	int i,j;
	for (i=1;i<len;i++)
	{
		tmp= arr[i];
		for (j=i-1;j>=0;j--)
		{
			if ( arr[j] > tmp)
				arr[j+1]=arr[j];
			else
				break;
		}
		arr[j+1]=tmp;
	}
}
 
 
void test_insert_sort()
{
	ELE_TYPE arr[] = { 61, 17, 29, 22, 34, 60, 72, 21, 50, 1, 62 };
	int len = (int) sizeof(arr) / sizeof(arr[0]);
	
	printf("Original data are:");
	print_array(arr, len);
 
	insert_sort(arr, len);
	printf("The data after sorted are:");
	print_array(arr, len);	
 
}
